From c946944be5915bc0b5f704c13da6c5ac80a73d9c Mon Sep 17 00:00:00 2001 From: Siddharth Agarwal Date: Thu, 3 Aug 2017 18:45:59 -0700 Subject: [PATCH] derive Debug for more data structures This makes it easier for wrappers around Cargo to inspect the contents of these data structures. --- src/cargo/core/manifest.rs | 2 +- src/cargo/core/package.rs | 2 +- src/cargo/core/workspace.rs | 3 +++ src/cargo/util/toml/mod.rs | 20 ++++++++++---------- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/cargo/core/manifest.rs b/src/cargo/core/manifest.rs index 662a5cbe4..75c09c5e2 100644 --- a/src/cargo/core/manifest.rs +++ b/src/cargo/core/manifest.rs @@ -17,7 +17,7 @@ pub enum EitherManifest { } /// Contains all the information about a package, as loaded from a Cargo.toml. -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct Manifest { summary: Summary, targets: Vec, diff --git a/src/cargo/core/package.rs b/src/cargo/core/package.rs index bdb7f41d4..493c2a248 100644 --- a/src/cargo/core/package.rs +++ b/src/cargo/core/package.rs @@ -18,7 +18,7 @@ use util::errors::{CargoResult, CargoResultExt}; /// /// A package is a `Cargo.toml` file plus all the files that are part of it. // TODO: Is manifest_path a relic? -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct Package { // The package's manifest manifest: Manifest, diff --git a/src/cargo/core/workspace.rs b/src/cargo/core/workspace.rs index ad53fc5b5..148e1e9ff 100644 --- a/src/cargo/core/workspace.rs +++ b/src/cargo/core/workspace.rs @@ -18,6 +18,7 @@ use util::toml::read_manifest; /// A workspace is often created very early on and then threaded through all /// other functions. It's typically through this object that the current /// package is loaded and/or learned about. +#[derive(Debug)] pub struct Workspace<'cfg> { config: &'cfg Config, @@ -57,11 +58,13 @@ pub struct Workspace<'cfg> { // Separate structure for tracking loaded packages (to avoid loading anything // twice), and this is separate to help appease the borrow checker. +#[derive(Debug)] struct Packages<'cfg> { config: &'cfg Config, packages: HashMap, } +#[derive(Debug)] enum MaybePackage { Package(Package), Virtual(VirtualManifest), diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index 84eb68f65..fcf5a98d1 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -142,7 +142,7 @@ type TomlExampleTarget = TomlTarget; type TomlTestTarget = TomlTarget; type TomlBenchTarget = TomlTarget; -#[derive(Serialize)] +#[derive(Debug, Serialize)] #[serde(untagged)] pub enum TomlDependency { Simple(String), @@ -181,7 +181,7 @@ impl<'de> de::Deserialize<'de> for TomlDependency { } } -#[derive(Deserialize, Serialize, Clone, Default)] +#[derive(Deserialize, Serialize, Clone, Debug, Default)] pub struct DetailedTomlDependency { version: Option, path: Option, @@ -197,7 +197,7 @@ pub struct DetailedTomlDependency { default_features2: Option, } -#[derive(Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize)] pub struct TomlManifest { package: Option>, project: Option>, @@ -224,7 +224,7 @@ pub struct TomlManifest { badges: Option>>, } -#[derive(Deserialize, Serialize, Clone, Default)] +#[derive(Deserialize, Serialize, Clone, Debug, Default)] pub struct TomlProfiles { test: Option, doc: Option, @@ -233,7 +233,7 @@ pub struct TomlProfiles { release: Option, } -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct TomlOptLevel(String); impl<'de> de::Deserialize<'de> for TomlOptLevel { @@ -282,7 +282,7 @@ impl ser::Serialize for TomlOptLevel { } } -#[derive(Clone, Serialize)] +#[derive(Clone, Debug, Serialize)] #[serde(untagged)] pub enum U32OrBool { U32(u32), @@ -325,7 +325,7 @@ impl<'de> de::Deserialize<'de> for U32OrBool { } } -#[derive(Deserialize, Serialize, Clone, Default)] +#[derive(Deserialize, Serialize, Clone, Debug, Default)] pub struct TomlProfile { #[serde(rename = "opt-level")] opt_level: Option, @@ -378,7 +378,7 @@ impl<'de> de::Deserialize<'de> for StringOrBool { } } -#[derive(Deserialize, Serialize, Clone)] +#[derive(Deserialize, Serialize, Clone, Debug)] pub struct TomlProject { name: String, version: semver::Version, @@ -404,7 +404,7 @@ pub struct TomlProject { metadata: Option, } -#[derive(Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize)] pub struct TomlWorkspace { members: Option>, exclude: Option>, @@ -966,7 +966,7 @@ impl ser::Serialize for PathValue { } /// Corresponds to a `target` entry, but `TomlTarget` is already used. -#[derive(Serialize, Deserialize)] +#[derive(Serialize, Deserialize, Debug)] struct TomlPlatform { dependencies: Option>, #[serde(rename = "build-dependencies")] -- 2.30.2